Is there a way to optimize this code for subplots in python

join shbcf.ru